<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>订单详情</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/common.js"></script>
    <script src="../../js/customer.js"></script>
</head>
<body>
<div id="orderDetailDiv">

</div>
<!-- <section class="tabbtnarea">
    <li class="w33 rline"><span class="tabfouse">订单信息</span></li>
    <li class="w33 rline">订单轨迹</li>
    <li class="w33">费用明细</li>
</section>
<section class="itemgroup mt44">
    <div class="order_title">
        订单编号: JJ1609120001<label class="type ml5">APP</label>
        <label class="right green">进行中</label>
    </div>
    <div class="twoitem ml15">
        <div class="w50 left">
            <label class="itemsubname">下单时间</label>
            <label class="font14">2017/5/4 12:59:59</label>
        </div>
        <div class="w50 right">
            <label class="itemsubname">预订时间</label>
            <label class="font14">2017/5/4 12:59:59</label>
        </div>
    </div>
    <div class="photoitem ml15 font14">
        <i class="iconfont mr5 green icon20">&#xe70d;</i>
        共和新路3288弄3号
    </div>
    <div class="photoitem ml15 font14">
        <i class="iconfont mr5 red icon20">&#xe70c;</i>
        共和新路3288弄3号
    </div>
    <div class="oneitem p15">
        <label class="gray font12">特殊要求:</label>
        <div class="comments_type right">备注</div>
        <div class="comments_type right mr5">搬运</div>
        <div class="comments_type right mr5">回单</div>
    </div>
</section>
<section class="subtitle p15 mt10">我的司机</section>
<section class="itemgroup">
    <div class="normalitem">
        <div class="userphoto"><img src="../../img/user_photo.png" width="100%" height="100%"/></div>
        <div class="photoitem lh24">
            <div class="itemname">
                方大同
                <span class="right gray font12">5.5公里</span>
            </div>
            <div class="itemsubname">湖北武汉<span class="mr5 ml5">|</span>驾龄4年</div>
            <div class="itemsubname">
                <i class="iconfont star_sm">&#xe640;</i>
                <i class="iconfont star_sm">&#xe640;</i>
                <i class="iconfont star_sm">&#xe640;</i>
                <i class="iconfont star_sm">&#xe640;</i>
                服务48次
            </div>
        </div>
    </div>
    <div class="orderitem p15 lh40 font14">
        车牌号:沪A12345
        <button class="btn right orderbtn">联系TA</button>
        <button class="btnkuang_bl right orderbtn mr5">收藏司机</button>
    </div>
</section>
<section class="itemgroup mt10">
    <div class="order_title">
        给司机捎句话
    </div>
    <div class="pall15 font14 lh24">不要迟到,盖雨布</div>
</section> -->
<input type="hidden" name="waybillId" id='waybillId'/>
</body>
<script> 
    $(function () {
        //token验证
        checkToken();
    });
    $(function () {
        var LocString = String(window.document.location.href);
        var waybillId = GetArgsFromHref("waybillId");
        $("#waybillId").val(waybillId);
        var customerUuid = getCookie("customerUuid");
        var url = _global.serverHost + "/consignerOrderManger/orderOkDetail.htm";
        var data = {
            'waybillId': waybillId,
            'customerUuid': customerUuid
        };
        _callAjaxRequest(url, data, callBack);

        function callBack(data) {
            var orderDetailDivhtml = '';

            var waybill = data.waybill;


            orderDetailDivhtml = orderDetailDivhtml + ' <section class="tabbtnarea">'
                + ' <li class="w33 rline"><span class="tabfouse">订单信息</span></li>'
                + ' <li class="w33 rline" onclick="goWaybillTrack(' + waybill.waybillId + ')">订单轨迹</li>'
                + ' <li class="w33" onclick="goFeeDetail(' + waybill.waybillId + ')">费用明细</li>'
                + '</section>';
            orderDetailDivhtml = orderDetailDivhtml + ' <section class="itemgroup mt44">'
                + ' <div class="order_title">'
                + ' 订单编号: ' + waybill.waybillNum;

            if (waybill.waybillSource == '10') {
                orderDetailDivhtml = orderDetailDivhtml + '<label class="type ml5">APP</label>';
            } else if (waybill.waybillSource == '20') {
                orderDetailDivhtml = orderDetailDivhtml + '<label class="type ml5">网站</label>';
            } else if (waybill.waybillSource == '30') {
                orderDetailDivhtml = orderDetailDivhtml + '<label class="type ml5">客服电话</label>';
            }

            orderDetailDivhtml = orderDetailDivhtml + ' <label class="right green">';

            if (waybill.status == '30') {
                orderDetailDivhtml = orderDetailDivhtml + '进行中';
            } else if (waybill.status == '40') {
                orderDetailDivhtml = orderDetailDivhtml + '就位';
            } else if (waybill.status == '50') {
                orderDetailDivhtml = orderDetailDivhtml + '装货完成';
            } else if (waybill.status == '60') {
                orderDetailDivhtml = orderDetailDivhtml + '到达目的地';
            } else if (waybill.status == '70') {
                orderDetailDivhtml = orderDetailDivhtml + '完成卸货';
            } else if (waybill.status == '80') {
                orderDetailDivhtml = orderDetailDivhtml + '等待评价';
            } else if (waybill.status == '90') {
                orderDetailDivhtml = orderDetailDivhtml + '订单完成';
            } else {
                orderDetailDivhtml = orderDetailDivhtml + '待处理';
            }

            orderDetailDivhtml = orderDetailDivhtml + '</label>'
                + ' </div>'
                + ' <div class="twoitem ml15">'
                + ' <div class="w50 left">'
                + ' <label class="itemsubname">下单时间</label>'
                + '<label class="font14">' + waybill.orderDate + '</label>'
                + '</div>'
                + '<div class="w50 right">'
                + '<label class="itemsubname">预订时间</label>'
                + ' <label class="font14">' + waybill.bookDates + '</label>'
                + '</div>'
                + '</div>';
                
                var  startStreet=waybill.startDistrict+waybill.startStreet;
                var  endStreet=waybill.endDistrict+waybill.endStreet;
                
                if(startStreet==undefined){
                	startStreet='';
                }
                if(endStreet==undefined){
                	endStreet='';
                }
            orderDetailDivhtml = orderDetailDivhtml + '<div class="photoitem ml15 font14">'
                + '<i class="iconfont mr5 green icon20">&#xe70d;</i>'
                +startStreet+ waybill.startAddr
                + ' </div>'
                + ' <div class="photoitem ml15 font14">'
                + ' <i class="iconfont mr5 red icon20">&#xe70c;</i>'
                + endStreet+ waybill.endAddr
                + '</div>';
            var requireList = data.requireList;

            if (requireList != undefined && requireList != null && requireList.length > 0) {
                orderDetailDivhtml = orderDetailDivhtml + '<div class="oneitem p15">'
                    + ' <label class="gray font12">特殊要求:</label>';

                for (var j = 0; j < requireList.length; j++) {
                    if (j > 0) {
                        orderDetailDivhtml = orderDetailDivhtml + '<div class="comments_type right mr5 ">';
                    } else {
                        orderDetailDivhtml = orderDetailDivhtml + '<div class="comments_type right ">';
                    }
                    orderDetailDivhtml = orderDetailDivhtml + '' + requireList[j].requirementName + '</div>';
                }
                orderDetailDivhtml = orderDetailDivhtml + '  </div>';
            }

            orderDetailDivhtml = orderDetailDivhtml + '</section>';
            if (waybill.driverId != undefined && waybill.driverId != null && waybill.driverId != '') {

                orderDetailDivhtml = orderDetailDivhtml + '<section class="subtitle p15 mt10">我的司机</section>'
                    + '<section class="itemgroup">'
                    + '<div class="normalitem">'
                    + '<div class="userphoto"><img src="../../img/user_photo.png" width="100%" height="100%"/></div>'
                    + '<div class="photoitem lh24">'
                    + '<div class="itemname">'
                    + waybill.driverName
                    + '<span class="right gray font12">';

                if (waybill.distance == undefined || waybill.distance == null || waybill.distance == '') {
                    orderDetailDivhtml = orderDetailDivhtml + waybill.planDistance;
                } else {
                    orderDetailDivhtml = orderDetailDivhtml + waybill.distance;
                }

                orderDetailDivhtml = orderDetailDivhtml + '   公里'
                    + '</span>'
                    + ' </div>'
                    + '<div class="itemsubname">';
                <!-- 湖北武汉<span class="mr5 ml5">| -->
                var consignDriver = data.consignDriver;

                orderDetailDivhtml = orderDetailDivhtml + '</span>驾龄' + consignDriver.drivedAge + '年</div>';
                +'<div class="itemsubname">';

                var consignDriverAssessSum = data.consignDriverAssessSum;
                if (consignDriverAssessSum.assessCount * 1 > 0) {
                    var score = consignDriverAssessSum.score * 1;
                    for (var j = 0; j < score; j++) {
                        orderDetailDivhtml = orderDetailDivhtml + '<i class="iconfont star_sm">&#xe640;</i>';
                    }
                } else {
                    orderDetailDivhtml = orderDetailDivhtml + '暂无评分';
                }

                orderDetailDivhtml = orderDetailDivhtml + '服务' + consignDriver.driverOrderCount + '次'
                    + ' </div>'
                    + '</div>'
                    + ' </div>';
                orderDetailDivhtml = orderDetailDivhtml + '<div class="orderitem p15 lh40 font14">'
                    + '车牌号:' + waybill.vehicleNum
                    + ' <a href="tel:' + waybill.driverMobile + '"> <button class="btn right orderbtn">联系TA</button></a>';
                if (consignDriver.consignDriverId == undefined || consignDriver.consignDriverId == null || consignDriver.consignDriverId == '') {
                    orderDetailDivhtml = orderDetailDivhtml + '<button style="display:none;" class="btnkuang_bl right orderbtn mr5" onclick="saveDriver(\'' + waybill.consignUserId + '\',\'' + waybill.driverId + '\')">收藏司机</button>';
                } else {
                    orderDetailDivhtml = orderDetailDivhtml + '<button style="display:none;" class="btnkuang_bl right orderbtn mr5" onclick="cancelDriver(\'' + consignDriver.consignDriverId + '\')">取消收藏</button>';
                }

                orderDetailDivhtml = orderDetailDivhtml + '</div>'
                    + '</section>';
            }
            if (waybill.consignDesc == undefined) {
                waybill.consignDesc = '';
            }

            orderDetailDivhtml = orderDetailDivhtml + '<section class="itemgroup mt10">'
                + '<div class="order_title">'
                + '给司机捎句话'
                + '</div>'
                + '<div class="pall15 font14 lh24">' + waybill.consignDesc + '</div>'
                + '</section> ';

            $("#orderDetailDiv").html(orderDetailDivhtml);

        }
    });

    //收藏司机
    function saveDriver(consignUserId, driverId) {

        var url = _global.serverHost + "/consignerDriver/collectionDriver.htm";
        $.ajax({
            type: "POST",
            url: url,
            data: {"consignUserId": consignUserId, "driverId": driverId},
            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
            success: function (data) {

                if (data.outResult == "1") {
                    var waybillId = $("#waybillId").val();
                    window.location.href = _global.serverHost + "/html/customer/order/order_detail.html?waybillId=" + waybillId;
                } else {
                    alert(data.outResultReason);
                }
            }
        });

    }
    //取消收藏
    function cancelDriver(consignerDriverId) {
        var url = _global.serverHost + "/consignerDriver/deleteCollection.htm";
        $.ajax({
            type: "POST",
            url: url,
            data: {"consignerDriverId": consignerDriverId},
            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
            success: function (data) {
                if (data.outResult == "1") {
                    var waybillId = $("#waybillId").val();
                    window.location.href = "../../customer/order/order_detail.html?waybillId=" + waybillId;
                } else {
                    alert(data.outResultReason);

                }
            }
        });

    }

    function goFeeDetail(waybillId) {
        //费用明细
        // window.location.href="${pageContext.request.contextPath}/consignerOrderManger/orderFeeDetail.htm?waybillId="+waybillId;
        window.location.href = "../../customer/order/price_detail.html?waybillId=" + waybillId;
    }

    //运单轨迹
    function goWaybillTrack(waybillId) {
        // window.location.href="${pageContext.request.contextPath}/consignerOrderManger/orderTrack.htm?waybillId="+waybillId;
        window.location.href = "../../customer/order/order_trace.html?waybillId=" + waybillId;
    }


</script>
</html>